/*
 * Stack.cpp
 *
 *  Created on: 29-06-2013
 *      Author: Jarek
 */

#include "Stack.h"

template <typename TYPE>
Stack<TYPE>::Stack()
{

}

template <typename TYPE>
Stack<TYPE>::Stack(uint size) :
	stackSize		(size),
	index			(0)
{
	stack = new TYPE[size];
}

template <typename TYPE>
Stack<TYPE>::~Stack()
{
	DELETE_ARRAY(stack);
}

template <typename TYPE>
void Stack<TYPE>::push(const TYPE& type)
{
	stack[index++] = type;
}

template <typename TYPE>
void Stack<TYPE>::pop()
{
	stack[--index].~TYPE();
}

template <typename TYPE>
TYPE& Stack<TYPE>::top() const
{
	return stack[index-1];
}

template <typename TYPE>
void Stack<TYPE>::clear()
{
	while (index)
		pop();
}

template <typename TYPE>
bool Stack<TYPE>::isEmpty() const
{
	return index == 0 ? true : false;
}

template <typename TYPE>
uint Stack<TYPE>::getSize() const
{
	return index;
}

template <typename TYPE>
uint Stack<TYPE>::getMaxSize() const
{
	return stackSize;
}
